a = {'zero': '0', 'one': '1', 'two': '2', 'three': '3', 'four': '4', 'five': '5', 'six': '6', 'seven': '7', 'eight': '8', 'nine': '9'}
def div(n):
    if n == 1:return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0: return False
    return True
b = input().split()
f = ''
for i in b:
    if i in a.keys() and len(b) == 3:
        f = True
    else:
        f = False
if f: 
    s = []
    for i in b:
        s.append(a.get(i))
    s = int(''.join(s))
    b = []
    for i in range(s - 10, s + 11):
        if div(i):
            b.append(i)
    print(b[1])
else:
    print('Wrong input')
